<template>
  <div class="classdetail">
    <div class="bg" ref="bg">
      <i class="iconfont icon-biaoqing" v-tap="{methods:back}"></i>
      <img :src="imgsrc" alt />
      <p>
        <span>{{title}}</span>
      </p>
    </div>
    <van-sticky>
      <div class="navbar">
        <div class="nav_left">
          <i class="iconfont icon-fenlei" v-tap="{methods:one}"></i>
          <i class="iconfont icon-yk_fangkuai_fill" v-tap="{methods:two}"></i>
        </div>

        <div class="nav_right">
          <van-dropdown-menu active-color="#000">
            <van-dropdown-item v-model="value1" :options="option" />
          </van-dropdown-menu>
          <span v-tap="{methods:tap}">
            <i class="iconfont icon-jia" ref="change"></i>筛选
            <van-popup
              v-model="show"
              position="right"
              :overlay="false"
              :style="{ width: '40%',height:'94%',marginTop:'23px'}"
              :close-on-click-overlay="false"
            >
              <div>
                <p>转角沙发</p>
                <p>多人沙发</p>
                <p>贵妃座</p>
                <p>单人沙发</p>
              </div>
              <div>
                <p>布艺</p>
                <p>皮革</p>
                <p>呢衣面料</p>
              </div>
              <div>
                <p>大坐深</p>
                <p>大坐宽</p>
                <p>可拆洗</p>
                <p>模块化</p>
                <p>高靠背</p>
              </div>
            </van-popup>
          </span>
        </div>
      </div>
    </van-sticky>
    <div class="one" v-if="flag">
      <van-grid :border="false" :column-num="2" :gutter="10">
        <van-grid-item v-for="item in list" :key="item.pid" v-tap="{methods:detail,id:item.pid}">
          <van-image :src="item.pimg" />
          <div class="info">
            <h4 class="title">{{item.pname}}</h4>
            <p class="price">￥{{item.pprice}}</p>
          </div>
        </van-grid-item>
      </van-grid>
    </div>
    <div class="two" v-if="!flag">
      <van-grid :border="false" :column-num="1">
        <van-grid-item v-for="item in list" :key="item.pid" v-tap="{methods:detail,id:item.pid}">
          <van-image :src="item.pimg" />
          <div class="info">
            <h4 class="title">{{item.pname}}</h4>
            <p class="price">￥{{item.pprice}}</p>
          </div>
        </van-grid-item>
      </van-grid>
    </div>
  </div>
</template>

<script>
import * as api from "../api/getProlist";
export default {
  name: "classdetail",
  data() {
    return {
      value1: 0,
      option: [
        { text: "推荐排序", value: 0 },
        { text: "新品优先", value: 1 },
        { text: "价格升序", value: 2 },
        { text: "价格降序", value: 2 }
      ],
      show: false,
      title: "",
      imgsrc: "",
      flag: true,
      list:[]
    };
  },
  methods: {
    tap() {
      this.show = !this.show;
      if (this.show) {
        this.$refs.change.setAttribute("class", "iconfont icon-jian");
        this.$refs.bg.style.display = "none";
      } else {
        this.$refs.change.setAttribute("class", "iconfont icon-jia");
        this.$refs.bg.style.display = "block";
      }
    },
    one() {
      this.flag = !this.flag;
      //this.$router.push("/classdetailone?id="+this.$route.query.id);
    },
    two() {
      this.flag = !this.flag;
      //this.$router.push("/classdetailtwo?id="+this.$route.query.id);
    },
    back() {
      this.$router.go(-1);
    },
    detail(id){
      this.$router.push("/ProdDetail?id=" + id.id);
    }
  },
  mounted() {
    if (this.$route.query.id == 1) {
      this.title = "沙发 Sofa";
      this.imgsrc = "http://img.zaozuo.com/3a3dc95bee7965b80057fda98b5bf264";
    } else if (this.$route.query.id == 2) {
      this.title = "休闲椅 Lounge Chair";
      this.imgsrc = "http://img.zaozuo.com/e1b12c45d012c335f10a7ba194deea81";
    } else if (this.$route.query.id == 3) {
      this.title = "椅凳 Chair";
      this.imgsrc = "http://img.zaozuo.com/40f47bddcdb2405655d9cbc181480291";
    } else if (this.$route.query.id == 4) {
      this.title = "坐墩 Pouf";
      this.imgsrc = "http://img.zaozuo.com/4ca7b3e0d71f5c188fa9d0b1624ee666";
    } else if (this.$route.query.id == 5) {
      this.title = "床 Bed";
      this.imgsrc = "http://img.zaozuo.com/e79ba7fe55e25df3b039d61792f55f53";
    } else if (this.$route.query.id == 6) {
      this.title = "床垫 Mattress";
      this.imgsrc = "http://img.zaozuo.com/346ce242f951da785ccd9b50bca2437c";
    } else if (this.$route.query.id == 7) {
      this.title = "床头柜 Nightstand";
      this.imgsrc = "http://img.zaozuo.com/211172386ff69628535e09c3f6c36472";
    } else if (this.$route.query.id == 8) {
      this.title = "床尾凳 Bed End Stool";
      this.imgsrc = "http://img.zaozuo.com/cc9cafb19283a15db936989eb56fc4be";
    } else if (this.$route.query.id == 9) {
      this.title = "床品4件套 Sheet Set";
      this.imgsrc = "http://img.zaozuo.com/8edaec721742e54741b0e5d5aef44086";
    } else if (this.$route.query.id == 10) {
      this.title = "被褥 Comforter";
      this.imgsrc = "http://img.zaozuo.com/3c89cb9e82f4cc446b78cbe02979e06e";
    } else if (this.$route.query.id == 11) {
      this.title = "枕芯 Pillow";
      this.imgsrc = "http://img.zaozuo.com/1c285cddde8b249ff098b514f62a5fbf";
    } else if (this.$route.query.id == 12) {
      this.title = "茶几 Tea Table";
      this.imgsrc = "http://img.zaozuo.com/22eb3e0fff8675b5df6762b2a3f79887";
    } else if (this.$route.query.id == 13) {
      this.title = "边桌 Side Table";
      this.imgsrc = "http://img.zaozuo.com/ffdcfff6fbd18059d58a68e6eaf4938e";
    } else if (this.$route.query.id == 14) {
      this.title = "餐桌·书桌 Table & Desk";
      this.imgsrc = "http://img.zaozuo.com/f5e1268b63a1358b521f5231aec04aee";
    } else if (this.$route.query.id == 15) {
      this.title = "梳妆台 Dressing Table";
      this.imgsrc = "http://img.zaozuo.com/ad9691d6c6c0f004d13858bd1063886a";
    } else if (this.$route.query.id == 16) {
      this.title = "地灯 Floor Lamp";
      this.imgsrc = "http://img.zaozuo.com/510285c89bbf9d506f81f75e593f36b7";
    } else if (this.$route.query.id == 17) {
      this.title = "吊灯 Pendant Lamp";
      this.imgsrc = "http://img.zaozuo.com/c45ed579dad9a14a56b49f1fd4cbea26";
    } else if (this.$route.query.id == 18) {
      this.title = "台灯 Table Lamp";
      this.imgsrc = "http://img.zaozuo.com/8ef4bbc514143a9d57a3cc723e12585b";
    } else if (this.$route.query.id == 19) {
      this.title = "吸顶灯 Ceiling Lamp";
      this.imgsrc = "http://img.zaozuo.com/7d4fbb3eec8a7c2741d596a139c2d39a";
    } else if (this.$route.query.id == 20) {
      this.title = "餐具 Dining Ware";
      this.imgsrc = "http://img.zaozuo.com/e3358fbbd39ed93e3c2ea7fef91d98ed";
    } else if (this.$route.query.id == 21) {
      this.title = "杯子 Cup";
      this.imgsrc = "http://img.zaozuo.com/e51c62d3e73dd546ad9d60be191156eb";
    } else if (this.$route.query.id == 22) {
      this.title = "托盘·果盘 Tray";
      this.imgsrc = "http://img.zaozuo.com/1ea89a28e4361faaa84576968df12a69";
    } else if (this.$route.query.id == 23) {
      this.title = "食品储物 Food Storage";
      this.imgsrc = "http://img.zaozuo.com/5e5bc3287817b8b860166d252e6db987";
    } else if (this.$route.query.id == 24) {
      this.title = "花瓶 Vase";
      this.imgsrc = "http://img.zaozuo.com/9806ca0bcfa07eaa68c34bc5c7914f2e";
    } else if (this.$route.query.id == 25) {
      this.title = "装饰画 Painting";
      this.imgsrc = "http://img.zaozuo.com/8a9970ebd53de665442b9177313e6af1";
    } else if (this.$route.query.id == 26) {
      this.title = "摆件 Decoration";
      this.imgsrc = "http://img.zaozuo.com/aef858646cbc16aad692479b0adc55d0";
    } else if (this.$route.query.id == 27) {
      this.title = "收纳 Storage";
      this.imgsrc = "http://img.zaozuo.com/eed5a516fadcef5cbbf132cf79391420";
    } else if (this.$route.query.id == 28) {
      this.title = "墙镜 Wall Mirror";
      this.imgsrc = "http://img.zaozuo.com/e8246c384443e771531a3070c62e7f13";
    } else if (this.$route.query.id == 29) {
      this.title = "床品4件套 Sheet Set";
      this.imgsrc = "http://img.zaozuo.com/8edaec721742e54741b0e5d5aef44086";
    } else if (this.$route.query.id == 30) {
      this.title = "被褥 Comforter";
      this.imgsrc = "http://img.zaozuo.com/3c89cb9e82f4cc446b78cbe02979e06e";
    } else if (this.$route.query.id == 31) {
      this.title = "枕芯 Pillow";
      this.imgsrc = "http://img.zaozuo.com/1c285cddde8b249ff098b514f62a5fbf";
    } else if (this.$route.query.id == 32) {
      this.title = "毛巾·浴巾 Towel";
      this.imgsrc = "http://img.zaozuo.com/008da5c28979fab0278d78f73bb647f6";
    } else if (this.$route.query.id == 33) {
      this.title = "盖毯·围巾 Blanket";
      this.imgsrc = "http://img.zaozuo.com/e1bce9a2522241ad95b76c6e328d6f45";
    } else if (this.$route.query.id == 34) {
      this.title = "地毯·地垫 Carpet";
      this.imgsrc = "http://img.zaozuo.com/e3ecc365efba3e679b24bc31055578cf";
    } else if (this.$route.query.id == 35) {
      this.title = "抱枕·颈枕 Cushion";
      this.imgsrc = "http://img.zaozuo.com/5d84d7eb3210110509823143f9a3748c";
    } else if (this.$route.query.id == 36) {
      this.title = "围巾 Scraf";
      this.imgsrc = "http://img.zaozuo.com/72f28b4f3f4eb057e1a3efa3ebe083b3";
    }
    api.getProdNameDel({ pname: this.title.slice(0, 1) }).then(data => {
      this.list = data.data.result;
    });
  }
};
</script>

<style scoped>
.van-ellipsis {
  font-size: 30px;
}
.bg {
  width: 100%;
  position: relative;
}
.bg .icon-biaoqing {
  position: absolute;
  font-size: 50px;
  color: #fff;
  margin-top: 20px;
  margin-left: 20px;
}

.bg img {
  width: 100%;
  display: block;
  height: 360px;
}
.bg > p {
  text-align: center;
  position: absolute;
  top: 100px;
  width: 100%;
}
.bg span {
  font-weight: bold;
  color: #fff;
  font-size: 50px;
  height: 50px;
}
.navbar {
  width: calc(100% - 60px);
  height: 90px;
  padding: 0 30px;
  background-color: #fff;
}
.navbar .nav_left {
  float: left;
  line-height: 80px;
}
.navbar .nav_left i {
  font-size: 52px;
  padding: 15px;
  vertical-align: middle;
}
.navbar .nav_left i:nth-of-type(2) {
  font-size: 38px;
  padding: 10px;
  vertical-align: middle;
}

.navbar .nav_right {
  float: right;
  line-height: 90px;
  font-size: 26px;
}
/deep/.van-ellipsis {
  font-size: 26px;
}
.navbar .nav_right span {
  padding: 0 5px;
  font-size: 26px;
  vertical-align: middle;
}
.van-dropdown-menu {
  margin-right: 20px;
  display: inline-block;
  height: 50px;
}
.van-ellipsis {
  font-size: 26px;
}
.navbar .nav_right span i {
  font-size: 30px;
  vertical-align: middle;
}
.van-popup {
  padding: 0 40px;
  border-top: solid 1px #eee;
}
.van-popup > div {
  border-bottom: solid 1px #eee;
}
.van-popup div:last-child {
  border: 0;
}

.van-popup div p {
  margin: 0;
  line-height: 3;
}

.one .van-ellipsis {
  font-size: 30px;
}
.one .van-grid {
  width: calc(100% - 20px);
  padding-left: 20px !important;
}
.one .van-grid-item div {
  padding: 0;
}
.one .van-grid-item .van-image {
  width: 100%;
  height: 400px;
}

.one .info {
  text-align: center;
}
.one .title {
  padding: 0;
  margin: 20px 0;
  font-size: 30px;
}
.one .sup {
  font-size: 12px;
  font-weight: normal;
}
.one .price {
  margin: 5px 0;
}


.two .van-ellipsis{
    font-size:30px;
}
.two .van-grid {
  width: 100%;
  padding: 0 !important;
}
.two .van-grid-item div {
  padding: 0;
}
.two .van-image{
  display: block;
  width: 100%;
  height:700px;
}
.two .info {
  text-align: center;
}
.two .title {
  padding: 0;
  margin: 20px 0;
  font-size: 30px;
}
.two .sup {
  font-size: 12px;
  font-weight: normal;
}
.two .price {
  margin: 5px 0;
}
</style>